//------------------------------------------------------------
//  Filename: accessory_wrapper.v
//   
//  Author  : wlduan@gmail.com
//  Revise  : 2016-10-11 11:47
//  Description: 
//   
//  Copyright (C) 2014, YRBD, Inc. 					      
//  All Rights Reserved.                                       
//-------------------------------------------------------------
//
`timescale 1ns/1ps

module ACCESSORY_WRAPPER (
    input  wire        clk_25mhz         , 
    input  wire        clk_100mhz        , 
    input  wire        resetn            , 
    output wire        slow_clk30k_out   , 
    
    input  wire        pwr_touch         ,     
    input  wire [10:0] pl_keys           , 
    output wire [10:0] plh_keys          , 
    output wire        key_intr          , 
    input  wire [10:0] func_keys         , 

    input  wire        pl_clk            ,
    input  wire        force_pwr_off     ,  
    output wire        soft_pwr_off      , 
    output wire        pwr_ctrl          ,

    input  wire        xadc_init         , 
    input  wire        vp_in             ,
    input  wire        vn_in             , 
    input wire         tp_in             ,
    input wire         tn_in             , 
    
    output wire [15:0] temp_value        ,   
    output wire [15:0] vpin_value        , 
    output wire [15:0] vtmp_value        ,      
    output wire [15:0] vint_value        ,   
    output wire [15:0] vaux_value        ,   

    input  wire [31:0] gaoya_time        , 
    input  wire [7:0]  gaoya_force       , 
    input  wire [31:0] gaoya_ctrl_time   , 
    input  wire [7:0]  gaoya_ctrl_force  , 

    output wire        dac_sclk          , 
    output wire        dac_sdata         , 
    output wire        dac_load          , 
    output wire        gaoya             , 
     
    input  wire        heat_mode         ,
    output wire        heat_status       , 
    input  wire [7:0]  heat_speed        , 
    input  wire [15:0] heat_time         , 
    input  wire        heat_touch        ,
    input  wire        heat_test         , 
    input  wire        hall_touch        ,
    input  wire        posl_touch        ,
    input  wire        posr_touch        ,  
    output wire [7:0]  touch_status      ,    
    output wire        heat              , 
    output wire        heat_ledon        , 
    input  wire [31:0] beep_cntr         , 
    input  wire [31:0] tone_divider      , 
    output wire        beep              , 
    input  wire [31:0] rtc_ctrl          , 
    output wire [15:0] rtc_data_read     , 
    output wire        rtc_trans_over    , 
    output wire        rtc_scl           , 
    inout  wire        rtc_sda           ,
    input  wire        load_time         , 
    input  wire [31:0] pcf8563_date      , 
    input  wire [31:0] pcf8563_time      , 
    output wire [31:0] local_date        , 
    output wire [31:0] local_time        
);      
//--------------------------------------------------------
wire rst = ~resetn;
wire slow_clk1k_out;

wire heat_key      = func_keys[8]; 
wire fusion_touch  = func_keys[9]; 
wire init_touch    = func_keys[10];
wire pwr_key       = func_keys[11];
//--------------------------------------------------------
keypro keypro_inst0(
    .sys_clk_100m    ( clk_100mhz      ) ,
    .sys_rstn        ( resetn          ) ,

    .slow_clk30k_out ( slow_clk30k_out ) ,
    .slow_clk1k_out  ( slow_clk1k_out  ) ,
    
    .heat_touch      ( heat_touch      ) ,
    .hall_touch      ( hall_touch      ) ,
    .posl_touch      ( posl_touch      ) ,
    .posr_touch      ( posr_touch      ) ,  
    .init_touch      ( init_touch      ) ,
    .fusion_touch    ( fusion_touch    ) ,
    .touch_status    ( touch_status    ) ,  

    .key             ( pl_keys         ) ,
    .keyout          ( plh_keys        ) ,
    .key_intr        ( key_intr        ) 
);

PWR_PROC PWR_PROC_inst0( 
    .pl_clk          ( pl_clk          ) ,

    .force_pwr_off   ( force_pwr_off   ) ,
    .pwr_touch       ( pwr_touch       ) ,
    .soft_pwr_off    ( soft_pwr_off    ) ,
    .pwr_ctrl        ( pwr_ctrl        )
);      

VOLTAGE_PROC VOLTAGE_PROC_inst0( 
    .clk             ( clk_25mhz       ) ,
    .rst             ( rst             ) ,

    .xadc_init       ( xadc_init       ) , 
    .vp_in           ( vp_in           ) ,
    .vn_in           ( vn_in           ) ,
    .tp_in           ( tp_in           ) ,
    .tn_in           ( tn_in           ) ,
    
	.temp_value      ( temp_value      ) ,
	.vpin_value      ( vpin_value      ) ,
	.vtmp_value      ( vtmp_value      ) ,
	.vint_value      ( vint_value      ) ,
	.vaux_value      ( vaux_value      ) 
);

GAOYA_PROC GAOYA_PROC_inst0( 
    .clk_25mhz   ( clk_25mhz   ) ,
    .clk_100mhz  ( clk_100mhz  ) ,
    .rst         ( rst         ) ,

    .gaoya_time  ( gaoya_time  ) ,
    .gaoya_force ( gaoya_force ) ,

    .gaoya_ctrl_time ( gaoya_ctrl_time  ), 
    .gaoya_ctrl_force( gaoya_ctrl_force ), 

    .dac_sclk    ( dac_sclk    ) ,
    .dac_sdata   ( dac_sdata   ) ,
    .dac_load    ( dac_load    ) ,
    .gaoya       ( gaoya       ) 
);  
HEAT_PROC HEAT_PROC_inst0( 
    .clk_1khz    ( slow_clk1k_out ) ,
    .rst         ( rst         ) ,

    .heat_mode   ( heat_mode   ) ,
    .heat_status ( heat_status ) ,
    .heat_speed  ( heat_speed  ) ,
    .heat_time   ( heat_time   ) ,
    .heat_key    ( heat_key    ) ,
    .heat_touch  ( heat_touch  ) ,
    .heat_test   ( heat_test   ) ,
    .vtmp_value  ( vtmp_value  ) ,
     
    .heat        ( heat        ) ,
    .heat_ledon  ( heat_ledon  ) 
);
SPEAKER_PROC SPEAKER_PROC_inst0( 
    .clk_100mhz   ( clk_100mhz   ) ,
    .rst          ( rst          ) ,

    .beep_cntr    ( beep_cntr    ) ,
    .tone_divider ( tone_divider ) ,
    .beep         ( beep         ) 
);
CALENDAR CALENDAR_inst0( 
    .clk_100mhz     ( clk_100mhz     ) ,
    .resetn         ( resetn         ) ,

    .rtc_ctrl       ( rtc_ctrl       ) ,
    .rtc_data_read  ( rtc_data_read  ) ,
    .rtc_trans_over ( rtc_trans_over ) ,

    .rtc_scl        ( rtc_scl        ) ,
    .rtc_sda        ( rtc_sda        ) ,

    .load_time      ( load_time      ) ,
    .pcf8563_date   ( pcf8563_date   ) ,
    .pcf8563_time   ( pcf8563_time   ) ,

    .local_date     ( local_date     ) ,
    .local_time     ( local_time     ) 
);  

endmodule
